import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main, dungeon
from util import *

class Scroll(sim.Scroll):
    def __init__(self):
        sim.Scroll.__init__(self, "shining egress", "?", colors['Lime'])

    def read(self, reader):
        rgbU = random.choice(['Red', 'Crimson', 'Pink', 'DeepPink'])
        rgbD = random.choice(['SpringGreen', 'Teal', 'Green', 'Lime'])
        self.uLight = parole.map.LightSource(colors[rgbU], 10.0)
        self.dLight = parole.map.LightSource(colors[rgbD], 10.0)

        self.map, self.upPos, self.downPos = main.levels[main.currentLevel]
        self.uLight.apply(self.map, self.upPos)
        self.dLight.apply(self.map, self.downPos)
        self.map.update()

        main.schedule.add(sim.Event('expire effect', main.schedule.time + 2*60000,
            (self,), dests=[self]))

    def listen(self, event):
        sim.Scroll.listen(self, event)

        if event.id == 'expire effect' and event.args[0] is self:
            self.uLight.remove(self.map)
            self.dLight.remove(self.map)
            self.map.update()


#========================================
thingClass = Scroll
